package org.example.code.test2024.ten_mouth;

import java.util.Arrays;

public class test1025 {

    public int maxTotalReward(int[] rewardValues) {
        int sum = 0;
        boolean[] flag = new boolean[rewardValues.length];
        Arrays.fill(flag, true);
        for (int i = 0; i < rewardValues.length; i++) {
            int min = i;
            for(int j=0;j<rewardValues.length;j++){
                if(rewardValues[j] > sum && rewardValues[j] < rewardValues[min]&&flag[j]){
                    min=j;
                }
            }
            flag[min] = false;
            sum=sum+rewardValues[min];
        }
        return sum;
    }
}
